'use strict';


var Product = require('../../models/productModel');


module.exports = function (router) {


    router.get('/', function (req, res) {

        Product.find(function (err, prods) {          // find()是mongodb对象的一个方法
            if (err) {
                console.log(err);
            }
            prods.forEach(function(prod) {
                prod.prettyPrice = prod.prettyPrice();
            });
            var model = {
                products: prods
            };
        console.log("Product: " + model.products);
            res.render('all', model);
        });

    });

};
